;; EX-01.scm - Using Arguments/Parameters/Controls.

;; It is useful to be able to specify the parameters of a synth when
;; it is created.  Here a synth is defined where a frequency argument
;; is declared to control a sine oscillator.

(require (lib "rsc.ss" "rsc"))

(server-boot)

(synthdef-send
 (synthdef
  "sine"
  ((freq 800))
  (Out.ar 0 (SinOsc.ar freq 0 0.1))))

;; Make two instances of the instrument.

(let ((f (lambda (n) (-> "/s_new" "sine" -1 1 1 "freq" n))))
  (f 400) 
  (f 800))

;; Set the 0 index control at all nodes in group 1 to 200.  Note that
;; SC3 does the correct type coercion for incoming packets.

(-> "/n_set" (exact->inexact 1) #i0.0 200)

;; Free all nodes at group 1.

(-> "/g_freeAll" 1)
